package cn.tjd.jwttest.controller;

import cn.tjd.jwttest.config.anno.PassToken;
import cn.tjd.jwttest.config.mvc.BaseController;
import cn.tjd.jwttest.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: TJD
 * @Date: 2020-02-02
 * @DESCRIPTION:
 **/
@RestController
public class UserController extends BaseController {

    @Autowired
    private UserService userService;


    @PostMapping("/login")
    @PassToken
    public String login(String username, String passwd) {
        String token = userService.login(username, passwd);
        if (token == null) {
            return "用户名或密码错误";
        }
        return token;
    }
}
